import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:hx_base/pages/imagelistview/hx_imagelistview.dart';

class ListImagePage extends StatelessWidget {
  ListImagePage({super.key});

  List dataList = [
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114159479303172750&projectId=113123515189125544"
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114159500017219379&projectId=113123515189125544",
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114159501719271266&projectId=113123515189125544"
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114159510595251328&projectId=113123515189125544"
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114159512921892825&projectId=113123515189125544"
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114537717307306728&projectId=113123515189125544"
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114537763544948376&projectId=113123515189125544"
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114537774737202975&projectId=113123515189125544"
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114159434521521940&projectId=113123515189125544"
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114159432977317079&projectId=113123515189125544"
      ]
    },
    {
      "name": "测试223124234242342测试",
      "image": [
        "http://192.168.2.86:9081/backend/backendserver/mapi/devops/feedback/downloadAttachment?id=114159431134994284&projectId=113123515189125544"
      ]
    },
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("图片列表"),
      ),
      body: bodyView(),
    );
  }

  bodyView() {
    return ListView.builder(
      itemBuilder: setItemBuilder,
      itemCount: dataList.length,
    );
  }

  Widget setItemBuilder(BuildContext context, int index) {
    var item = dataList.elementAt(index);
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 10.h),
      margin: EdgeInsets.fromLTRB(16, 0, 16, 10),
      child: Column(
        children: [
          Container(
            margin: EdgeInsets.fromLTRB(10, 10, 10, 10),
            child: Text(item["name"]),
          ),
          HxImagelistview<String>(
              list: item["image"],
              getImageUrl: (item) => item,
              width: (ScreenUtil().screenWidth - 50) / 3,
              height: 200),
        ],
      ),
    );
  }
}
